#include "RBTree.h"
#include "AVLTree.h"
#include <vector>

void Func1()
{
	int a[] = { 16, 3, 7, 11, 9, 26, 18, 14, 15 };
	RBTree<int, int> t;
	for (auto e : a)
	{
		t.Insert(make_pair(e, e));
	}
	t.InOrder();
	cout << t.IsBalance() << endl;
	cout << t.Size() << endl;
	cout << t.Height() << endl;
	cout << t.getRotateSize() << endl;
}

void Func2()
{
	int a[] = { 16, 3, 7, 11, 9, 26, 18, 14, 15 };
	AVLTree<int, int> t;
	for (auto e : a)
	{
		t.Insert(make_pair(e, e));
	}
	t.InOrder();
	cout << t.IsBalance() << endl;
	cout << t.Size() << endl;
	cout << t.Height() << endl;
	cout << t.getRotateSize() << endl;
}

void Func3()
{
	RBTree<int, int> t1;
	AVLTree<int, int> t2;

	const int N = 10000000;
	vector<int> v;
	v.reserve(N);
	srand(time(0));

	for (size_t i = 0; i < N; i++)
	{
		v.push_back(rand() + i);
	}

	size_t begin1 = clock();
	for (auto e : v)
	{
		t1.Insert(make_pair(e, e));
	}
	size_t end1 = clock();
	
	size_t begin2 = clock();
	for (auto e : v)
	{
		t2.Insert(make_pair(e, e));
	}
	size_t end2 = clock();

	cout << "RBTree RoateSize:" << t1.getRotateSize() << endl;
	cout << "AVLTree RoateSize:" << t2.getRotateSize() << endl;
	
	cout << "RBTree Insert:" << end1 - begin1 << endl;
	cout << "AVLTree Insert:" << end2 - begin2 << endl;
	
	cout << "RBTree IsBalance:" << t1.IsBalance() << endl;
	cout << "AVLTree IsBalance:" << t2.IsBalance() << endl;
	
	cout << "RBTree Height:" << t1.Height() << endl;
	cout << "AVLTree Height:" << t2.Height() << endl;

	cout << "RBTree Size:" << t1.Size() << endl;
	cout << "AVLTree Size:" << t2.Size() << endl;
}
int main()
{
	Func3();

	return 0;
}
